﻿using LanguagePolish.Base;
using LanguagePolish.EntityModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LanguagePolish.ViewModels
{
    class AddClassViewModel : BaseViewModel
    {
        public Class Class { get; private set; }
        public string Title { get; private set; }

        public bool HasErrors
        {
            get { return Class.HasErrors; }
        }

        public IEnumerable<Classroom> Classrooms
        {
            get { return LinksProvider.Model.EntityContext.Classrooms.ToList(); }
        }

        public IEnumerable<Teacher> Teachers
        {
            get { return LinksProvider.Model.EntityContext.Teachers.ToList(); }
        }

        public IEnumerable<Level> Levels
        {
            get { return LinksProvider.Model.EntityContext.Levels.ToList(); }
        }
          
        public AddClassViewModel(Class myClass, bool isEdit)
        {
            Class = myClass;
            InitTitle(isEdit);
        }

        private void InitTitle(bool isEdit)
        {
            Title = isEdit ? "Edit Class" : "Add New Class";
            OnPropertyChanged("Title");
        }

    }
}
